import java.util.Set;
import java.util.TreeSet;

/**
 * Created with Intellij IDEA.
 * Description;
 * User:墨琦
 * Data:2023-09-21
 * Time:10:25
 */
public class Java_1 {
    public static int lengthOfLongestSubstring(String s) {
        Set<Character> t1=new TreeSet<>();
        int num=0;
        for( int left=0,right=0;left<s.length();left++)
        {
            while(right<s.length()&&t1.add(s.charAt(right))!=false)
            {
                num=Math.max(num,right-left+1);
                right++;
            }
            t1.remove(s.charAt(left));
        }
        return num;
    }
    public static void main(String[] args) {
        String abd="pwwkew";
        int a=lengthOfLongestSubstring(abd);
        System.out.println(a);
    }
}
